<%--
	User: dizem@126.com
	Time: 11-6-23 上午10:52
--%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta http-equiv=content-type content="text/html; charset=UTF-8"/>
  <script type="text/javascript" src="../js/jquery-1.6.js"></script>
  <script type="text/javascript" src="../js/jquery-ui-1.8.14.custom.min.js"></script>
  <script type="text/javascript" src="http://api.map.baidu.com/api?v=1.1&services=true"></script>
  <link rel="stylesheet" href="../css/index.css" type="text/css" media="screen" charset="utf-8"/>
  <link rel="stylesheet" href="../css/comment.css" type="text/css" media="screen" charset="utf-8"/>
  <script type="text/javascript" src="../js/item.js"></script>
  <script type="text/javascript" src="../js/order.js"></script>
  <title>今日团购</title>


  <script type="text/javascript">
    
    function openOrderDialog() {
      var username = "<%=session.getAttribute("SESSION_USERNAME")%>";
      if (username == null || username == "" || username == "null") {
        confirm("下订单必须先登录<br/><br/>是否登录？", "提示", function() {
          $("#dialog-login").dialog("open");
        });
      } else {
        $("#dialog-order").dialog("open");
      }
      return false;
    }

    function openCommentDialog() {
      var username = "<%=session.getAttribute("SESSION_USERNAME")%>";
      if (username == null || username == "" || username == "null") {
        confirm("评价商品必须先登录<br/><br/>是否登录？", "提示", function() {
          $("#dialog-login").dialog("open");
        });
      } else {
        $("#dialog-comment").dialog("open");
      }
    }
  </script>
</head>
<body>
<jsp:include page="../common/header.jsp"/>

<div id="bdw" class="bdw">
<div id="bd" class="cf">
<div id="deal-default">
<div id="content">
  <div id="deal-intro" class="cf">
    <div class="no">
      ${item.id}
    </div>
    <h1>
      <a class="deal-today-link" href="index.jsp">今日团购：${item.title}</a>
    </h1>

    <div class="main">
      <div class="deal-buy">
        <div class="deal-price-tag">
        </div>
        <p class="deal-price">
          <strong>${item.groupPrice}</strong>
					<span>
						<a href="#" onclick="return openOrderDialog();">
              <img src="../image/button-d.gif"/>
            </a>
					</span>
        </p>
      </div>
      <table class="deal-discount">
        <tr>
          <th>原价</th>
          <th>折扣</th>
          <th>节省</th>
        </tr>
        <tr>
          <td>
            <del>¥${item.marketPrice}</del>
          </td>
          <td>
            <fmt:formatNumber type="number" value="${item.groupPrice/item.marketPrice*10}"
                              maxFractionDigits="0"/>折
          </td>
          <td>¥${item.marketPrice-item.groupPrice}</td>

        </tr>
      </table>
      <div class="deal-box deal-timeleft deal-on" id="deal-timeleft-1">
        <c:choose>
          <c:when test="${item.timeState} == /^团购/">
            <h3>${item.timeState}</h3>
          </c:when>
          <c:otherwise>
            <h3>剩余时间</h3>

            <div>
              <ul id="counter-1">
                <p>
                    ${item.timeState}
              </ul>
            </div>
          </c:otherwise>
        </c:choose>
      </div>
      <div class="deal-box deal-status" id="deal-status">
        <p class="deal-buy-tip-top">
          <strong>${item.currentCount}</strong> 人已购买
        </p>

        <div class="progress-pointer" style="padding-left: 0;">
          <span></span>
        </div>
        <div class="progress-bar">
          <div class="progress-left" style="width: 0;">
          </div>
          <div class="progress-right" style="width:0">
          </div>
        </div>
        <div class="cf">
          <div class="min">${item.minCount}</div>
          <div class="max">${item.maxCount}</div>
        </div>
        <p class="deal-buy-tip-btm">
          还差<strong>${item.minCount - item.currentCount}</strong> 人到达最低团购人数
        </p>
      </div>
    </div>
    <div class="side">
      <div class="deal-buy-cover-img" id="team_images">
        <a href="#"><img src="/getImage.action?id=${item.image1.id}" style="max-height:100%;width:auto" border="0"/> </a>
      </div>
      <div class="digest">
        <img src="../image/bg-deal00.gif" alt="" style="margin-left:280px"><br>

        <h3>${item.feature}</h3>
      </div>
    </div>
  </div>
  <br>

  <div id="deal-stuff" class="cf">
    <div class="clear box box-split">
      <div class="box-top"></div>
      <div class="box-content cf">
        <div class="main">
          <div class="blk">
            <div class="detail">
              <p class="title"><strong>团购描述</strong></p>
              <ul>
                <%
                  String text = (String) request.getAttribute("item.description");
                  for (String line : text.split("\\[br\\]")) {
                    line = line.trim();
                    if (line.length() > 0)
                      out.println("<li class='contentInfo'>" + line + "</li>");
                  }
                %>
              </ul>
              </p>
            </div>
            <div>
              <img src="getImage.action?id=${item.image2.id}"/>
            </div>
            <div class="detail">
              <p class="title"><strong>温馨提示</strong></p>

              <p>
              <ul>
                <%
                  text = (String) request.getAttribute("item.tips");
                  for (String line : text.split("\\[br\\]")) {
                    line = line.trim();
                    if (line.length() > 0)
                      out.println("<li class='contentInfo'>" + line + "</li>");
                  }
                %>
              </ul>
              </p>
            </div>
            <div>
              <img src="getImage.action?id=${item.image3.id}" alt=""/>
            </div>
            <div class="detail">
              <p class="title"><strong>特别提示</strong></p>
              <ul>
                <%
                  text = (String) request.getAttribute("item.specialTips");
                  for (String line : text.split("\\[br\\]")) {
                    line = line.trim();
                    if (line.length() > 0)
                      out.println("<li class='contentInfo'>" + line + "</li>");
                  }
                %>
              </ul>
            </div>
            <jsp:include page="../common/sidebar/comments_bar.jsp"/>

          </div>
        </div>
        <div id="inner_side" class="side">
          <div id="side-business">
            <h2>${item.merchant.name}</h2>

            <div style="margin-top: 10px;">
              ${item.merchant.phoneNumber}
            </div>
            <div style="margin-top: 10px;">
              ${item.merchant.address}
            </div>
            <div style="margin-top: 10px;">
              <a href="${item.merchant.url}">${item.merchant.url}</a>
            </div>
            <br/>

            <div style="width:200px;height:200px;border:1px solid gray" id="map"></div>
            <script type="text/javascript">

              var map = new BMap.Map("map");
              var point = new BMap.Point(121.404 + Math.random() / 100, 31.2 + Math.random() / 100);
              map.centerAndZoom(point, 15);
              var opts = {
                width : 10,
                height: 15,
                title : "${item.merchant.name}"
              }
              var infoWindow = new BMap.InfoWindow("", opts);
              map.openInfoWindow(infoWindow, map.getCenter());
              map.enableScrollWheelZoom();
              map.enableKeyboard();
              map.addControl(new BMap.ScaleControl());
            </script>
          </div>
        </div>

      </div>
      <div class="box-bottom"></div>
      <a name="new-reply"></a>
    </div>
  </div>


</div>
<div id="sidebar">
  <jsp:include page="../common/sidebar/merchant_bar.jsp"/>
  <jsp:include page="../common/sidebar/faq_bar.jsp"/>
  <jsp:include page="../common/sidebar/link_bar.jsp"/>
</div>
</div>
</div>
</div>
<jsp:include page="../common/footer.jsp"/>
</body>
</html>


<div id="dialog-comment" title="发表评论" style="background:white">
  <div id="dialog-popup">
    <div class="sect">
      <s:form namespace="/" action="addReply" method="post" id="form-reply"
              theme="simple">
        <div class="field">
          <label for="txt_username">用户名</label>
          <input type="text" id="txt_username" size="10" name="username" readonly value="${SESSION_USERNAME}"
                 class="f-input"/>
        </div>
        <div class="field">
          <label>评分</label>

          <div class="ratings inline_block" style="cursor: pointer; margin:1px 0 1px 0;" tabindex="0">
            <div class="ratings_star ratings_star_on" onclick="doRating(1);"
                 title="1"></div>
            <div class="ratings_star ratings_star_on" onclick="doRating(2);"
                 title="2"></div>
            <div class="ratings_star ratings_star_on" onclick="doRating(3);"
                 title="3"></div>
            <div class="ratings_star ratings_star_on" onclick="doRating(4);"
                 title="4"></div>
            <div class="ratings_star ratings_star_on" onclick="doRating(5);"
                 title="5"></div>
          </div>
          <s:hidden id="rating_num" name="reply.rate" value="5"/>
          <input type="hidden" name="itemId" value="${item.id}"/>
        </div>
        <div class="field">
          <label for="txt_comment">评论内容</label>
          <s:textarea id="txt_comment" name="reply.message"
                      cssClass="f-textarea" cols="45" rows="5"/>
        </div>
        <s:submit name="commit" id="submit" cssClass="formsubmit"/>
      </s:form>
    </div>
  </div>
</div>
<jsp:include page="../common/dialog/order_dialog.jsp"/>